/*
** Copyright (C) 2010 Calin Radoni
**
** This file is part of CHScanner.
**
** CHScanner is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** CHScanner is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with CHScanner. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include "Messages.h"
#include "MWinSecurity.h"
#include "MEventLogRecord.h"

class MEventLog
{
private:
	MWinSecurity mws;

	CString applicationName;

	TCHAR buffer[MAX_PATH+1];

public:
	MEventLog(LPTSTR applicationNameIn);
	~MEventLog(void);

	// Categories should have the message id ranging from 1 -> CategoryCount
	// Use this when messages are embeded as resources
	bool RegisterThisAppAsSource(DWORD categCountIn);

	// Categories should have the message id ranging from 1 -> CategoryCount
	// Use this when messages are in a separate file (like a .dll)
	bool RegisterAsSource(LPTSTR msgFileName, DWORD categCountIn);

	// Write an application event to the application event log
	// Last parameter MUST be an empty string !
	bool ReportAnEvent(WORD type, WORD category, DWORD eventId, ...);

	// Write an application event with associated data to the application event log
	// Last parameter MUST be an empty string !
	bool ReportAnEventWithData(WORD type, WORD category, DWORD eventId,
			DWORD dataSize, LPVOID data, ...);

	HANDLE OpenAnEventLog(LPCTSTR machineNameIn, LPCTSTR logNameIn);
		bool ReadNextEventLogEntry(HANDLE, LPCTSTR machineNameIn, MEventLogRecord*);
		bool ClearAnEventLog(HANDLE, LPCTSTR backupFileName);
	bool CloseAnEventLog(HANDLE);
};
